package controller

import (
	"etcd/e"
	"etcd/utile"
	"github.com/gin-gonic/gin"
	"net/http"
)

var formHelper utile.FormHelper

func Success(c *gin.Context,data ...interface{}) {
	if len(data) > 0 {
		c.JSON(http.StatusOK, utile.ReturnData(e.SUCCESS, e.GetMsg(e.SUCCESS),data[0]))
		return
	}
	c.JSON(http.StatusOK, utile.ReturnData(e.SUCCESS, e.GetMsg(e.SUCCESS)))
	return
}

func Error(c *gin.Context,code int,message ...string) {
	if len(message) > 0 {
		c.JSON(http.StatusOK, utile.ReturnData(code, message[0]))
	} else {
		c.JSON(http.StatusOK, utile.ReturnData(code, e.GetMsg(code)))
	}
	return
}
